<template>
  <dialog class="modal fixed" open v-if="isOpen">
    <div class="modal-box">
      <h3 class="text-lg font-bold">{{ title }}</h3>
      <p class="py-4">{{ content }}</p>
      <div class="modal-action">
        <form method="dialog" class="flex gap-5">
          <button class="btn" @click="handleClose">{{ cancelText }}</button>
          <button class="btn btn-primary" @click="handleConfirm">
            {{ confirmText }}
          </button>
        </form>
      </div>
    </div>
  </dialog>
</template>
<script setup>
import { dialogJs } from "~/composables/common/dialog";
const { isOpen, title, content, link, confirmText, cancelText, diaLogHide } =
  dialogJs();
const handleClose = () => {
  diaLogHide();
};
const handleConfirm = () => {
  if (link.value) {
    window.location.href = link.value;
  }
  diaLogHide();
};
</script>
